import logging

import pytest

from resource.pom.contacts import Contacts


class Test:
    app = Contacts

    @pytest.mark.parametrize('setup_teardown', [app.bundle_name], indirect=True)
    def test(self, setup_teardown, device):
        "反复打开联系人应用，无卡死黑白屏等现象"
        for i in range(5):
            logging.info('步骤1.{}：打开或反复启动联系人应用'.format(i))
            device.start_ability(self.app.bundle_name, self.app.ability_name)
            logging.info('预期结果1.{}：联系人打开无卡死、黑屏、白屏等现象'.format(i))
            device.assert_current_window(self.app.window_name)
            device.refresh_layout()
            device.assert_text_exist('电话')
            device.assert_text_exist('全部通话')
            device.assert_text_exist('未接来电')
            device.assert_text_exist('1')
            device.assert_text_exist('2')
            device.assert_text_exist('3')
            device.assert_text_exist('4')
            device.assert_text_exist('5')
            device.assert_text_exist('6')
            device.assert_text_exist('7')
            device.assert_text_exist('8')
            device.assert_text_exist('9')
            device.assert_text_exist('0')
            device.assert_text_exist('联系人')
            device.assert_text_exist('收藏')
            device.go_back()
